<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('data_setting', false);	
my_component_load('materi_pelatihan' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$modulname = "Admin _BN_ Konfigurasi Data";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "hobicreate" :
		   $validatepost = form_materi_pelatihan_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_materi_pelatihan_create($id);
				generate_my_web($content,"","plain.php");
				exit;
			}else{
				form_materi_pelatihan_submit($id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			my_direct('index.php?com=materi_pelatihan');
			break;
	}

else: 	
	if($task == "editmateri_pelatihan"){
		$title= ($id > '0' ) ?  "Perubahan data materi pelatihan" : "Tambah data materi pelatihan";
		facebox_page('index.php?com=materi_pelatihan&task=hobicreate&id='.$id , $title , 210	); 
	}elseif($task == "hobicreate"){ 
		$content  = form_materi_pelatihan_create($id);
		generate_my_web($content,"","plain.php");
		exit; 
	}elseif($task == "materidelete"){ 
		 delete_materi($id);
		 my_direct($_SERVER['HTTP_REFERER']);
		exit; 		
	}else{
		$pagename = "Daftar materi pelatihan";
		load_facebox_script();
		$view =  list_materi_pelatihan(); 
		$href = 'index.php?com=materi_pelatihan&task=editmateri_pelatihan&id=0' ;	
	}
endif;  
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname." _BN_ Materi Pelatihan" );
?>